package com.sky.controller.admin;

import com.sky.constant.StatusConstant;
import com.sky.mapper.SetmealMapper;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.service.OrdersService;
import com.sky.service.SetmealService;
import com.sky.vo.BusinessDataVO;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.OrderOverViewVO;
import com.sky.vo.SetmealOverViewVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;


@RestController
@RequestMapping("/admin/workspace")
@Api(tags = "工作台相关接口")
@Slf4j
public class WorkSpaceController {


    @Autowired
    SetmealService setmealService;

    @Autowired
    DishService dishService;

    @Autowired
    OrdersService ordersService;

    @GetMapping("/overviewSetmeals")
    @ApiOperation("套餐总览")
    public Result<SetmealOverViewVO> overviewSetmeals() {
        log.info("套餐总览");
        SetmealOverViewVO setmealOverViewVO = setmealService.overviewSetmeals();
        return Result.success(setmealOverViewVO);
    }

    @GetMapping("/overviewDishes")
    @ApiOperation("菜品总览")
    public Result<DishOverViewVO> overviewDishes() {
        log.info("菜品总览");
        DishOverViewVO dishOverViewVO = dishService.overviewDishs();
        return Result.success(dishOverViewVO);
    }

    @GetMapping("/overviewOrders")
    @ApiOperation("订单总览")
    public Result<OrderOverViewVO> overviewOrders() {
        log.info("订单总览");
        OrderOverViewVO orderOverViewVO = ordersService.overviewOrders();
        return Result.success(orderOverViewVO);
    }

    @GetMapping("/businessData")
    @ApiOperation("运营数据统计")
    public Result<BusinessDataVO> businessData() {
        log.info("运营数据统计");
        BusinessDataVO businessDataVO = ordersService.businessData(LocalDate.now(), LocalDate.now());

        return Result.success(businessDataVO);
    }

}
